package com.ktwlrj.core.feign;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ktwlrj.core.base.ActionResult;
import com.ktwlrj.core.feign.args.FilesArgs;
import com.ktwlrj.core.feign.args.SysCredentialsConfigArgs;
import com.ktwlrj.core.feign.dto.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 基础平台接口
 *
 * @Author TY
 * @create 2019/6/5 15:18
 */
@FeignClient(value = "platform-plat", fallbackFactory = FeignFallback.class)
public interface FrameworkClient {
    @RequestMapping(value = "/admin_api/sys/users/currentUser?headerStrategy=frameworkSetToken", method = RequestMethod.GET)
    ActionResult<Object> getCurrentUser();

    /**
     * 根据机构类型编码获取所属机构列表
     *
     * @param orgTypeCode
     * @return ActionResult ${@link ActionResult}
     * @author zhouxuanhong
     * @date 2019-04-12 12:07
     */
    @RequestMapping(value = "/admin_api/sys/organizations/orgByTypeCode/open?headerStrategy=frameworkSetToken", method = RequestMethod.GET)
    ActionResult<List<OrgByTypeDto>> orgByTypeCode(@RequestParam("orgTypeCode") String orgTypeCode);


    /**
     * 查询我注册的企业列表
     *
     * @param memberId ${@link String}
     * @param orgName  ${@link String}
     * @param page     ${@link Integer}
     * @param size     ${@link Integer}
     * @param skip     ${@link Integer}
     * @param sorts    ${@link String}
     * @return ActionResult ${@link ActionResult}
     * @author zhouxuanhong
     * @date 2019-04-12 12:07
     */
    @RequestMapping(value = "/admin_api/sys/memberOrg/getRegisterPageList/open?headerStrategy=frameworkSetToken", method = RequestMethod.GET)
    ActionResult<Object> selectRegister(@RequestParam("memberId") String memberId,
                                        @RequestParam("orgName") String orgName,
                                        @RequestParam("page") Integer page,
                                        @RequestParam("size") Integer size,
                                        @RequestParam("skip") Integer skip,
                                        @RequestParam("sorts") String sorts);


    /**
     * 查询企业类型列表
     *
     * @return ActionResult ${@link ActionResult}
     * @author zhouxuanhong
     * @date 2019-04-09 12:31
     */
    @RequestMapping(value = "/admin_api/sys/memberOrg/getOrgTypeBusiList/open?headerStrategy=frameworkSetToken", method = RequestMethod.GET)
    ActionResult<Object> selectOrgType();


    /**
     * 查询企业列表
     *
     * @param memberId ${@link String}
     * @param orgName  ${@link String}
     * @param page     ${@link Integer}
     * @param size     ${@link Integer}
     * @param skip     ${@link Integer}
     * @param sorts    ${@link String}
     * @return ActionResult ${@link ActionResult}
     * @author zhouxuanhong
     * @date 2019-04-12 12:07
     */
    @RequestMapping(value = "/admin_api/sys/memberOrg/getOrgPageList/open?headerStrategy=frameworkSetToken", method = RequestMethod.GET)
    ActionResult<Object> selectOrganization(@RequestParam("memberId") String memberId,
                                            @RequestParam("orgName") String orgName,
                                            @RequestParam("page") Integer page,
                                            @RequestParam("size") Integer size,
                                            @RequestParam("skip") Integer skip,
                                            @RequestParam("sorts") String sorts);


    /**
     * 查询我加入的企业列表
     *
     * @param orgName ${@link String}
     * @param page    ${@link Integer}
     * @param size    ${@link Integer}
     * @param skip    ${@link Integer}
     * @param sorts   ${@link String}
     * @return ActionResult ${@link ActionResult}
     * @author zhouxuanhong
     * @date 2019-04-12 12:07
     */
    @RequestMapping(value = "/admin_api/sys/memberOrg/getApplyPageList/open?headerStrategy=frameworkSetToken", method = RequestMethod.GET)
    ActionResult<JSONObject> selectJoin(@RequestParam("memberId") String memberId,
                                        @RequestParam("orgName") String orgName,
                                        @RequestParam("page") Integer page,
                                        @RequestParam("size") Integer size,
                                        @RequestParam("skip") Integer skip,
                                        @RequestParam("sorts") String sorts);


    /**
     * 获取行政区划下拉树
     *
     * @return ActionResult ${@link ActionResult}
     * @author zhouxuanhong
     * @date 2019-04-12 12:07
     */
    @RequestMapping(value = "/admin_api/sys/memberOrg/getRegionSelectTree/open?headerStrategy=frameworkSetToken", method = RequestMethod.GET)
    ActionResult<List<RegionTreeResult>> getRegionSelectTree();


    /**
     * 查询企业用户机构注册时机构类型信息
     *
     * @param memberId         ${@link String} 会员id
     * @param socialCreditCode ${@link String} 统一社会信用代码
     * @return ActionResult ${@link ActionResult}
     * @author zhouxuanhong
     * @date 2019-04-12 12:07
     */
    @RequestMapping(value = "/admin_api/sys/memberOrg/getMemberOrgFind/open?headerStrategy=frameworkSetToken", method = RequestMethod.GET)
    ActionResult<Object> getMemberOrgFind(@RequestParam("memberId") String memberId, @RequestParam("socialCreditCode") String socialCreditCode);


    /**
     * 查询注册企业审核状态
     *
     * @param socialCreditCode ${@link String}  统一社会信息用代码
     * @return Integer ${@link Integer} -1--拒绝或未找到数据(-1为可提交注册)，0--申请中，1--通过
     * @author zhouxuanhong
     * @date 2019-04-18 14:42
     */
    @RequestMapping(value = "/admin_api/sys/memberOrg/getOrgRegisterAuditState/open?headerStrategy=frameworkSetToken", method = RequestMethod.GET)
    ActionResult<Integer> getMemberOrgAudit(@RequestParam("socialCreditCode") String socialCreditCode);


    /**
     * 开放平台获取企业注册列表
     *
     * @param memberOpenId ${@link String} 会员开放id
     * @param orgId        ${@link String} 机构id
     * @return Object ${@link Object}
     * @author zhouxuanhong
     * @date 2019-04-09 12:11
     */
    @RequestMapping(value = "/admin_api/sys/oauthClients/getOauthList/open?headerStrategy=frameworkSetToken", method = RequestMethod.GET)
    ActionResult<Object> getOauthList(@RequestParam("memberOpenId") String memberOpenId, @RequestParam("orgId") String orgId);


    /**
     * 获取当前用户注册机构
     *
     * @param memberOpenId ${@link String} 会员开放id
     * @return Object ${@link Object}
     * @author zhouxuanhong
     * @date 2019-04-09 12:11
     */
    @RequestMapping(value = "/admin_api/sys/memberOrg/getMemberOrgSelectList/open?headerStrategy=frameworkSetToken", method = RequestMethod.GET)
    ActionResult<JSONArray> getMemberOrgSelectList(@RequestParam("memberOpenId") String memberOpenId);


    /**
     * 获取当前用户基础平台配置权限信息
     *
     * @param memberOpenId ${@link String} 会员开放id
     * @return Object ${@link Object}
     * @author zhouxuanhong
     * @date 2019-04-09 12:11
     */
    @RequestMapping(value = "/admin_api/sys/memberOrg/getMemberUserPermission/open?headerStrategy=frameworkSetToken", method = RequestMethod.GET)
    ActionResult<List<PermissionInfo>> getMemberUserPermission(@RequestParam("memberOpenId") String memberOpenId,
                                                               @RequestParam("systemId") String systemId,
                                                               @RequestParam("orgId") String orgId);


    /**
     * 基础平台获取数据权限接口
     *
     * @param busiCode     ${@link String}
     * @param memberOpenId ${@link String}
     * @param orgId        ${@link String}
     * @return Object ${@link Object}
     * @author zhouxuanhong
     * @date 2019-06-18 14:11
     */
    @RequestMapping(value = "/admin_api/sys/memberOrg/getMenberDataPermission/open?headerStrategy=frameworkSetToken", method = RequestMethod.GET)
    ActionResult<JSONObject> getMenberDataPermission(@RequestParam("memberOpenId") String memberOpenId,
                                                     @RequestParam("busiCode") String busiCode,
                                                     @RequestParam("orgId") String orgId);


    /**
     * 通过统一社会信用代码查询集购物orgId
     *
     * @param socialCreditCode ${@link String}
     * @return Object ${@link Object}
     * @author zhouxuanhong
     * @date 2019-06-18 14:11
     */
    @RequestMapping(value = "/admin_api/sys/organizations/orgIdBySocialCreditCode/open?headerStrategy=frameworkSetToken", method = RequestMethod.GET)
    ActionResult<String> getOrgIdBySocialCreditCode(@RequestParam("socialCreditCode") String socialCreditCode);


    /**
     * 取号
     *
     * @param tnRuleCode 取号编码
     * @param regionCode 区域编码
     * @param sysId      系统编号
     * @return
     */
    @RequestMapping(value = "/admin_api/sys/tnrules/takeNumber/open?headerStrategy=frameworkSetToken", method = RequestMethod.GET)
    ActionResult<String> takeNumber(@RequestParam("tnRuleCode") String tnRuleCode,
                                    @RequestParam("regionCode") String regionCode,
                                    @RequestParam("sysId") String sysId);


    /**
     * 查询当前机构下的所有人员openId
     *
     * @param orgId ${@link String}
     * @return String[] ${@link String[]}
     * @author zhouxuanhong
     * @date 2019-09-12 17:17
     */
    @RequestMapping(value = "/admin_api/sys/member/openIdByOrgId/open?headerStrategy=frameworkSetToken", method = RequestMethod.GET)
    ActionResult<String[]> getOpenIdByOrgId(@RequestParam("orgId") String orgId);


    /**
     * 获取数据字典
     *
     * @param systemId       ${@link String}
     * @param dictionaryCode ${@link String}
     * @param regionCode     ${@link String}
     * @return ActionResult<JSONArray> ${@link ActionResult<JSONArray>}
     * @author zhouxuanhong
     * @date 2019-09-12 17:17
     */
    @RequestMapping(value = "/admin_api/sys/dictionaries/groupwithcommon/open?headerStrategy=frameworkSetToken", method = RequestMethod.GET)
    ActionResult<JSONArray> getDic(@RequestParam("systemId") String systemId,
                                   @RequestParam("dictionaryCode") String dictionaryCode,
                                   @RequestParam("regionCode") String regionCode);


    /**
     * 获取区域编码
     *
     * @return ActionResult<JSONArray> ${@link ActionResult<JSONArray>}
     * @author zhouxuanhong
     * @date 2019-09-12 17:17
     */
    @RequestMapping(value = "/admin_api/sys/regions/regionTrees/selectedAndEnabled/open?headerStrategy=frameworkSetToken", method = RequestMethod.GET)
    ActionResult<Object> getRegionTree();


    /**
     * 基础平台url上传文件接口
     *
     * @param filesModelList ${@link List<FilesArgs>}
     * @return ActionResult<String> ${@link ActionResult<String>}
     * @author zhouxuanhong
     * @date 2019-05-20 10:16
     */
    @PostMapping(value = "/ueditor/uploadUrlFile/open?headerStrategy=frameworkSetToken")
    ActionResult<List<UploadResult>> uploadUrlFile(@RequestBody List<FilesArgs> filesModelList);


    /**
     * 通过openId从机构踢出人员
     *
     * @param orgId  ${@link String}
     * @param openId ${@link String}
     * @return ActionResult<Object> ${@link ActionResult<Object>}
     * @author zhou
     * @date 2019-12-13 14:42
     */
    @GetMapping(value = "/admin_api/sys/memberOrgManage/outOrg/open?headerStrategy=frameworkSetToken")
    ActionResult<Object> removeMemberFromOrg(@RequestParam("orgId") String orgId,
                                             @RequestParam("openId") String openId);

    /**
     * 获取业务列表
     *
     * @param busiCodes 业务编码集合，之间用','分隔
     * @return ActionResult<Object> ${@link ActionResult<Object>}
     * @author zhou
     * @date 2019-12-13 14:42
     */
    @GetMapping(value = "/admin_api/sys/businesses/code/open?headerStrategy=frameworkSetToken")
    ActionResult<List<BusiSimpleInfo>> getBusiList(@RequestParam("busiCodes") String busiCodes);


    /**
     * 根据权限编码获取权限信息
     *
     * @param authCode 权限编码
     * @param version 版本号
     * @return ActionResult<DataAuthRuleResultModel> ${@link ActionResult<DataAuthRuleResultModel>}
     * @author zhou
     * @date 2019-12-13 14:42
     */
    @GetMapping(value = "/admin_api/sys/dataAuth/sql?headerStrategy=frameworkSetToken")
    ActionResult<List<DataAuthRuleResultModel>> getDataAuth(@RequestParam("authCode") String authCode, @RequestParam("version") Integer version);

    /**
     * 获取要件配置及明细信息
     *
     * @param systemId   系统编号
     * @param busiId     业务编号
     * @param regionCode 区域编码
     * @return
     */
    @RequestMapping(value = "/admin_api/sys/credentials/get/busi/busiConfigOrCredentials/open?headerStrategy=frameworkSetToken", method = RequestMethod.GET)
    ActionResult<List<SysCredentialsConfigArgs>> getBusiConfigOrCredentials(@RequestParam("systemId") String systemId,
                                                                            @RequestParam("busiId") String busiId,
                                                                            @RequestParam("regionCode") String regionCode);
}
